<% layout('/layouts/default.html', {title: '企业管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('企业管理')}
			</div>
			<div class="box-tools pull-right">
				<!--<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>-->
				<% if(hasPermi('company:comCompany:edit')){ %>
					<a href="${ctx}/company/comCompany/form" class="btn btn-default btnTool" title="${text('新增企业')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${comCompany}" action="${ctx}/company/comCompany/listData" method="post" class="form-inline"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<#form:hidden name="ctrlPermi" value="2"/>
				<div class="form-group">
					<label class="control-label">${text('企业名称')}：</label>
					<div class="control-inline">
						<#form:input path="name" maxlength="50" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('审核状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="checkStatus" dictType="com_check_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('机构')}：</label>
					<div class="control-inline width-120">
						<#form:treeselect id="office" title="${text('机构选择')}"
								path="employee.office.officeCode" labelPath="employee.office.officeName"
								url="${ctx}/sys/office/treeData?ctrlPermi=2" btnClass="btn-sm" allowClear="true" canSelectParent="true"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("企业名称")}', name:'name', index:'a.name', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/company/comCompany/form?id='+row.id+'" class="btnList" data-title="${text("编辑企业")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("所属区县")}', name:'county', index:'a.county', width:150, align:"center"},
		{header:'${text("监管单位")}', name:'refName', index:'a.ref_name', width:80, align:"center"},
		{header:'${text("企业类型")}', name:'type', index:'a.type', width:80, align:"center",formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('store_type')}, val, '${text("未知")}', true);
		}},
		{header:'${text("企业规模")}', name:'scale', index:'a.scale', width:150, align:"center"},
		{header:'${text("年度评级")}', name:'level', index:'a.level', width:80, align:"center"},
		{header:'${text("营业状态")}', name:'openStatus', index:'a.open_status', width:80, align:"center"},
		{header:'${text("联系人")}', name:'managerName', index:'a.manager_name', width:150, align:"center"},
		{header:'${text("联系电话")}', name:'managerPhone', index:'a.manager_phone', width:150, align:"center"},
		{header:'${text("录入时间")}', name:'createDate', index:'a.create_date', width:150, align:"center",formatter:function (val) {
			return val;
		}},
		{header:'${text("完善时间")}', name:'completeDate', index:'a.complete_date', width:150, align:"center",formatter:function (val) {
			return val == null ? "尚未完善" : val;
		}},

//		{header:'${text("审核状态")}', name:'checkStatus', index:'a.checkStatus', width:80, align:"center",formatter:function (val, obj, row, act) {
//			if (val == 0){
//				return '<label class="label label-warning">待审核</label>';
//			}else if (val == 1) {
//				return '<label class="label label-success">审核通过</label>';
//			}else if (val == 2) {
//				return '<label class="label label-default">审核不通过</label>';
//			}
//
//		}},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('company:comCompany:edit')){ %>
				actions.push('<a href="${ctx}/company/comCompany/form?id='+row.id+'" class="btnList" title="${text("编辑企业")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if(row.status==Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/company/comCompany/disable?id='+row.id+'" class="btnList" title="${text("停用企业")}" data-confirm="${text("确认要停用该企业吗？")}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				if(row.status==Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/company/comCompany/enable?id='+row.id+'" class="btnList" title="${text("启用企业")}" data-confirm="${text("确认要启用该企业吗？")}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/company/comCompany/delete?id='+row.id+'" class="btnList" title="${text("删除企业")}" data-confirm="${text("确认要删除该企业吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
